HAL EXTI Functions

Initialization/De-initialization and configuration functions

group EXTI_Exported_Functions_Group1

This subsection provides a set of functions to initialize, de-initialize, and configure the EXTI:

Initialize the EXTI handle using HAL_EXTI_Init():

  • Provide the EXTI handle as a parameter.

  • Provide the EXTI line number as a second parameter from hal_exti_line_t enumeration.

De-initialize the EXTI and reset the EXTI global state to HAL_EXTI_STATE_RESET by calling HAL_EXTI_DeInit():

  • Provide the EXTI handle as a parameter.

Configure the EXTI line using HAL_EXTI_SetConfig():

Retrieve the current EXTI configuration of a dedicated line using HAL_EXTI_GetConfig():

  • Provide the EXTI handle as the first parameter.

  • Provide a configuration structure used to retrieve the current EXTI line configuration.

Functions

hal_status_t HAL_EXTI_Init ( hal_exti_handle_t * hexti , hal_exti_line_t line )

Store the EXTI line into the handle.

Parameters :
  • hexti – Pointer to EXTI handle.

  • line – EXTI line. This parameter can be one of the values of hal_exti_line_t.

Return values :
  • HAL_INVALID_PARAM – In case of an invalid parameter.

  • HAL_OK – In case of a successful initialization.

void HAL_EXTI_DeInit ( hal_exti_handle_t * hexti )

De-initialize the EXTI line.

Parameters :

hexti – Pointer to EXTI handle.

hal_status_t HAL_EXTI_SetConfig ( hal_exti_handle_t * hexti , const hal_exti_config_t * p_exti_config )

Set configuration for the selected EXTI line.

Parameters :
  • hexti – Pointer to EXTI handle.

  • p_exti_config – Pointer to EXTI configuration structure.

Return values :
  • HAL_INVALID_PARAM – In case of an invalid parameter.

  • HAL_OK – In case of a successful configuration.

  • HAL_ERROR – In case of selected EXTI line is direct.

void HAL_EXTI_GetConfig ( const hal_exti_handle_t * hexti , hal_exti_config_t * p_exti_config )

Retrieve the configuration of the selected EXTI line.

Parameters :
  • hexti – Pointer to EXTI handle.

  • p_exti_config – Pointer to structure to store EXTI configuration.

I/O operation functions

group EXTI_Exported_Functions_Group2

This subsection describes the APIs that manage I/O operations for EXTI lines:

Enable the EXTI line for the selected mode: Interrupt, Event or both using HAL_EXTI_Enable():

  • Provide the EXTI handle as a first parameter.

  • Provide an EXTI mode from hal_exti_mode_t as a second parameter.

Disable EXTI line using HAL_EXTI_Disable():

  • Provide the EXTI handle as a parameter.

Generate a software interrupt using HAL_EXTI_GenerateSWI():

  • Provide the EXTI handle as a parameter.

Get interrupt pending edge using HAL_EXTI_GetPending():

  • Provide the EXTI handle as a parameter.

Clear interrupt pending bit for the given edge using HAL_EXTI_ClearPending():

  • Provide the EXTI handle as the first parameter.

  • Provide the pending edge as the second parameter.

Functions

hal_status_t HAL_EXTI_Enable ( hal_exti_handle_t * hexti , hal_exti_mode_t mode )

Enable the EXTI mode for the selected EXTI line.

Parameters :
  • hexti – Pointer to EXTI handle.

  • mode – EXTI mode. This parameter can be one of the values of hal_exti_mode_t.

Return values :

HAL_OK – In case of a successful enable.

hal_status_t HAL_EXTI_Disable ( hal_exti_handle_t * hexti )

Disable the EXTI mode for the selected EXTI line.

Parameters :

hexti – Pointer to EXTI handle.

Return values :

HAL_OK – In case of a successful disable.

hal_status_t HAL_EXTI_GenerateSWI ( hal_exti_handle_t * hexti )

Generate a software interrupt for the selected EXTI line.

Parameters :

hexti – Pointer to EXTI handle.

Return values :
  • HAL_OK – When software interrupt is successfully generated.

  • HAL_ERROR – In case of selected EXTI line is direct.

hal_exti_trigger_t HAL_EXTI_GetPending ( const hal_exti_handle_t * hexti )

Get interrupt pending bit of the selected EXTI line.

Parameters :

hexti – Pointer to EXTI handle.

Return values :

pending_edge – of type hal_exti_trigger_t Trigger value.

void HAL_EXTI_ClearPending ( const hal_exti_handle_t * hexti , hal_exti_trigger_t edge )

Clear interrupt pending bit of the selected EXTI line.

Parameters :
  • hexti – Pointer to EXTI handle.

  • edge – Pending edge to be cleared. This parameter can be one of the values of hal_exti_trigger_t Trigger value.

IRQHandler and callback functions

group EXTI_Exported_Functions_Group3

This subsection contains the EXTI IRQHandler and callback registration functions:

Handle EXTI interrupt requests using HAL_EXTI_IRQHandler():

  • Provide the EXTI handle as a parameter.

Register callback function for interrupts on trigger edge using HAL_EXTI_RegisterTriggerCallback():

  • Provide the EXTI handle as the first parameter.

  • Provide a pointer to the callback function as the second parameter.

Default callback function for interrupts on trigger edge using HAL_EXTI_TriggerCallback():

  • Provide the EXTI handle as a parameter.

  • Provide the trigger as the second parameter.

Store user data pointer into the handle using HAL_EXTI_SetUserData():

  • Provide the EXTI handle as the first parameter.

  • Provide the pointer to the user data as the second parameter.

Retrieve user data pointer from the handle using HAL_EXTI_GetUserData():

  • Provide the EXTI handle as a parameter.

Functions

void HAL_EXTI_IRQHandler ( hal_exti_handle_t * hexti )

Handle EXTI interrupt requests.

Parameters :

hexti – Pointer to EXTI handle.

hal_status_t HAL_EXTI_RegisterTriggerCallback ( hal_exti_handle_t * hexti , hal_exti_cb_t p_exti_cb )

Register callback function for the selected EXTI line on trigger edge.

Parameters :
  • hexti – Pointer to EXTI handle.

  • p_exti_cb – Pointer to the callback function to be registered.

Return values :
  • HAL_INVALID_PARAM – In case of an invalid parameter.

  • HAL_OK – In case of a successful callback registration.

void HAL_EXTI_TriggerCallback ( hal_exti_handle_t * hexti , hal_exti_trigger_t trigger )

EXTI line trigger edge default callback.

Parameters :
  • hexti – Pointer to EXTI handle.

  • trigger – This parameter can be one of the values of hal_exti_trigger_t Trigger value.

void HAL_EXTI_SetUserData ( hal_exti_handle_t * hexti , const void * p_user_data )

Store the user data pointer in the handle.

Parameters :
  • hexti – Pointer to EXTI handle.

  • p_user_data – Pointer to the user data.

const void * HAL_EXTI_GetUserData ( const hal_exti_handle_t * hexti )

Retrieve the user data pointer from the handle.

Parameters :

hexti – Pointer to EXTI handle.

Return values :

Pointer – to the user data.

EXTI state and info functions

group EXTI_Exported_Functions_Group4

This subsection contains the EXTI state and info functions:

Retrieve the global state of the current EXTI line using HAL_EXTI_GetState():

  • Provide the EXTI handle as a parameter.

Retrieve the HAL EXTI line using HAL_EXTI_GetInstance():

  • Provide the EXTI handle as a parameter.

Retrieve the LL EXTI line using HAL_EXTI_GetLLInstance():

  • Provide the EXTI handle as a parameter.

Functions

hal_exti_state_t HAL_EXTI_GetState ( const hal_exti_handle_t * hexti )

Get the current general state of the EXTI line.

Parameters :

hexti – Pointer to EXTI handle.

Return values :
  • HAL_EXTI_STATE_RESET – when EXTI is de-initialized.

  • HAL_EXTI_STATE_INIT – when EXTI is initialized but not yet configured.

  • HAL_EXTI_STATE_IDLE – when EXTI is initialized and configured.

  • HAL_EXTI_STATE_ACTIVE – when EXTI is initialized, configured, and enabled.

hal_exti_line_t HAL_EXTI_GetInstance ( const hal_exti_handle_t * hexti )

Get the HAL EXTI line.

Parameters :

hexti – Pointer to a hal_exti_handle_t structure.

Return values :

The – HAL EXTI line.

uint32_t HAL_EXTI_GetLLInstance ( const hal_exti_handle_t * hexti )

Get the LL instance from the handle.

Parameters :

hexti – Pointer to a hal_exti_handle_t structure.

Return values :

The – LL EXTI Line.

EXTI security attributes management

group EXTI_Exported_Functions_Group5

This subsection contains EXTI security attributes management functions:

Set the EXTI line privilege attribute using HAL_EXTI_SetPrivAttr():

  • Provide the EXTI line as first parameter.

  • Provide the EXTI privilege attribute as second parameter.

Get the EXTI line privilege attribute using HAL_EXTI_GetPrivAttr():

  • Provide the EXTI line as first parameter.

Functions

hal_status_t HAL_EXTI_SetPrivAttr ( hal_exti_line_t exti_line , hal_exti_priv_attr_t priv_attr )

Set the privileged access level attribute for an EXTI line.

Parameters :
Return values :
  • HAL_OK – Privilege attribute has been set successfully

  • HAL_ERROR – Non-privileged write to a privileged-only register.

hal_exti_priv_attr_t HAL_EXTI_GetPrivAttr ( hal_exti_line_t exti_line )

Get the privileged access level attribute for an EXTI line.

Parameters :

exti_line – This parameter can be one of the values of hal_exti_line_t.

Return values :

The – returned value can be one of the following values: